package com.we.risk.phoneRecord.common;

import com.we.risk.phoneRecord.stage2.adm.PhoneCallBasicInfo;
import com.we.risk.phoneRecord.stage2.adm.UserBasicInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static com.we.risk.phoneRecord.common.Stage2GlobalSetting.*;

public class PhoneRecordDataUtils {
    public static Logger LOG = LoggerFactory.getLogger(PhoneRecordDataUtils.class);
    public static final String mobRegex = "1[3-9][0-9]{9}$";
    public static final String fixRegex = "^(0[0-9]{2,3})?-?[2-9][0-9]{6,7}";
    public static final String ad400Regex = "^(400[0-9]{6,8})|(800[0-9]{6,8})";
    public static final String b9596Regex = "(95|96)[0-9]{3,4}";
    public static final String specRegex = "^(110|119|120|122|999|112|114|12395|12121|12117|12119|12110|10000|10001|10010|10086|10050|12306|118114|116114)$";

    public static Byte inBook(String callName) {
        if (callName == null || callName.equals("")) {
            return 0;
        } else {
            return 1;
        }
    }

    public static String getVarFormatedPhone(String phone) {
        if(phone != null) {
            phone = phone.replaceAll("[^\\d]", "").replaceAll("^0*(86)*0*", "");
        }
        return phone;
    }

    public static String getVarMobile(String varFormatedPhone) {
        if(varFormatedPhone != null) {
            return getRegexResStr(varFormatedPhone, mobRegex);
        }
        return null;
    }

    public static String getVarPhoneTags(String phone) {
        StringBuilder stringBuilder = new StringBuilder();
        phone = getVarFormatedPhone(phone);
        if(phone != null) {
            String mobPart = getRegexResStr(phone, mobRegex);
            if (mobPart != null && mobPart.length() > 0){
                stringBuilder.append("1");
            } else {
                stringBuilder.append("0");
            }

            String fixPart = getRegexResStr("0" + phone, fixRegex);
            if (fixPart != null && fixPart.length() > 0) {
                stringBuilder.append("1");
            } else {
                stringBuilder.append("0");
            }

            String ad400Part = getRegexResStr(phone, ad400Regex);
            if (ad400Part != null && ad400Part.length() > 0) {
                stringBuilder.append("1");
            } else {
                stringBuilder.append("0");
            }

            String b9596Part = getRegexResStr(phone, b9596Regex);
            if (b9596Part != null && b9596Part.length() > 0) {
                stringBuilder.append("1");
            } else {
                stringBuilder.append("0");
            }

            String specPart = getRegexResStr(phone, specRegex);
            if (specPart != null && specPart.length() > 0) {
                stringBuilder.append("1");
            } else {
                stringBuilder.append("0");
            }
        } else {
            stringBuilder.append("00000");
        }
        return stringBuilder.toString();
    }


    public static String forMattedPhoneNumber(String phone) {
        if (phone != null) {
            phone = phone.replaceAll("[^\\d]", "").replaceAll("^0*(86)*0*", "");
//            String mobRegex = "1[3-9][0-9]{9}$";
            String mobPart = getRegexResStr(phone, mobRegex);
            if (mobPart != null && mobPart.length() > 0) {
                return mobPart;
            } else {
//                String fixRegex = "^(0[0-9]{2,3})?-?[2-9][0-9]{6,7}";
                String fixPart = getRegexResStr("0" + phone, fixRegex);
                if (fixPart != null && fixPart.length() > 0) {
                    return fixPart;
                } else {
//                    String ad400Regex = "^(400[0-9]{6,8})|(800[0-9]{6,8})";
                    String ad400Part = getRegexResStr(phone, ad400Regex);
                    if (ad400Part != null && ad400Part.length() > 0) {
                        return ad400Part;
                    } else {
//                        String b9596Regex = "(95|96)[0-9]{3,4}";
                        String b9596Part = getRegexResStr(phone, b9596Regex);
                        if (b9596Part != null && b9596Part.length() > 0) {
                            return b9596Part;
                        } else {
//                            String specRegex =
//                                    "^(110|119|120|122|999|112|114|12395|12121|12117|12119|12110|10000|10001|10010|10086|10050|12306|118114|116114)$";
                            String specPart = getRegexResStr(phone, specRegex);
                            if (specPart != null && specPart.length() > 0) {
                                return specPart;
                            }
                        }
                    }
                }
            }
        }
        return null;
    }

    public static boolean isMobile(String phone) {
        if (phone != null) {
            String mobRegex = "^1[3-9][0-9]{9}$";
            String mobPart = getRegexResStr(phone, mobRegex);
            if (mobPart != null) {
                return (mobPart.length() > 0);
            }
            return false;
        }
        return false;
    }

    private static String getRegexResStr(String input, String pattern) {
        Pattern p = Pattern.compile(pattern);
        Matcher matcher = p.matcher(input);
        if (matcher.find()) {
            return matcher.group();
        }
        return null;
    }

    public static long timeBeforeDays(long now, int days) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(now);
        calendar.add(Calendar.DATE, -days);
        long res = calendar.getTimeInMillis();
        return res;
    }

    public static long getStartTimeOfDay(long now, SimpleDateFormat sdf) {
        String date = sdf.format(new Date(now));
        long res = 0;
        try {
            res = sdf.parse(date).getTime();
        } catch (Exception e) {
            LOG.error("sdf parse date error! time: " + now);
            e.printStackTrace();
        }
        return res;
    }

    private static int getHourOfTime(long now) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(now);
        int res = calendar.get(Calendar.HOUR_OF_DAY);
        return res;
    }

    public static String getHourGroup(long now) {
        int hour = getHourOfTime(now);
        if (hour > 0 && hour <= 6) {
            return BEMORNING;
        } else if (hour > 6 && hour <= 12) {
            return MORNING;
        } else if (hour > 12 && hour <= 18) {
            return AFTERNOON;
        } else {
            return NIGHT;
        }
    }

    public static String mapCallType(String type) {
        if (!type.equals("OUTGOING")
                && !type.equals("INCOMING")
                && !type.equals("REJECTED")
                && !type.equals("MISSED")
                && !type.equals("BLOCKED")) {
            return "UNKNOWN";
        } else {
            return type;
        }
    }

    public static String mapCsTag(String cstag) {
        if (cstag != null) {
            if (cstag.equals("cstag")) {
                return CS;
            } else {
                return "csOther";
            }
        } else {
            LOG.debug("mapCsTag input is null!!");
            return "csOther";
        }
    }

    public static String mapSougouType(String type) {
        if (type != null) {
            switch (type) {
                case "else":
                    return ELSE;
                case "保险":
                    return BAOXIAN;
                case "打车":
                    return DACHE;
                case "贷款":
                    return DAIKUAN;
                case "购物":
                    return GOUWU;
                case "广告":
                    return GUANGGAO;
                case "客服":
                    return KEFU;
                case "快递":
                    return KUAIDI;
                case "骚扰":
                    return SAORAO;
                case "外卖":
                    return WAIMAI;
                case "信用卡":
                    return XINYONGKA;
                case "银行":
                    return YINHANG;
                case "运营商":
                    return YUNYINGSHANG;
                case "中介":
                    return ZHONGJIE;
                default:
                    //                    LOG.warn("mapSougouType input error: " + type);
                    return "other";
            }
        } else {
            return "other";
        }
    }

    public static double getScore(UserBasicInfo user, PhoneCallBasicInfo callDetail, String num) {
        int user_bad_cnt = user.getBad_cnt();
        int user_income_cnt = user.getIncome_cnt();
        int user_outgo_cnt = user.getOutgo_cnt();
        int user_morning_cnt = user.getMorning_cnt();

        int user_time0_number = user.getTime0_number();
        int user_time60_number = user.getTime60_number();
        int user_outgo_number = user.getOutgo_number();
        int user_number = user.getUser_number();
        int user_bad_number = user.getbad_number();
        int user_morning_number = user.getMorning_number();
        int user_afternoon_number = user.getAfternoon_number();
        int user_night_number = user.getNight_number();

        double call_total_time = callDetail.getTotal_time();
        int call_cnt = callDetail.getCnt();
        double call_avg_time = callDetail.getAvg_time();
        int call_income_cnt = callDetail.getIncome_cnt();
        int call_bad_cnt = callDetail.getBad_cnt();
        int call_night_cnt = callDetail.getNight_cnt();
        int call_outgo_cnt = callDetail.getOutgo_cnt();
        int call_time0_cnt = callDetail.getTime0_cnt();
        int call_time60_cnt = callDetail.getTime60_cnt();
        int call_time10_cnt = callDetail.getTime10_cnt();
        int call_bemorning_cnt = callDetail.getBemorning_cnt();
        int call_afternoon_cnt = callDetail.getAfternoon_cnt();

        double score = Double.valueOf("0");
        double[] varList = new double[30];
        varList[0] = getVar0(user_bad_cnt, user_time60_number, call_bemorning_cnt);
        varList[1] = getVar1(call_night_cnt, user_time60_number);
        varList[2] = getVar2(call_time60_cnt, call_time10_cnt);
        varList[3] = getVar3(call_time60_cnt, user_bad_number);
        varList[4] = getVar4(call_cnt, call_avg_time);
        varList[5] = getVar5(call_outgo_cnt, user_morning_number, user_time0_number);
        varList[6] = getVar6(call_time60_cnt, user_morning_number);
        varList[7] = getVar7(call_cnt, call_night_cnt);
        varList[8] = getVar8(call_total_time, user_outgo_number);
        varList[9] = getVar9(call_time10_cnt, user_time0_number);
        varList[10] = getVar10(call_cnt, user_number);
        varList[11] = getVar11(call_time60_cnt, call_bemorning_cnt);
        varList[12] = getVar12(call_avg_time, user_bad_cnt);
        varList[13] = getVar13(call_outgo_cnt, call_afternoon_cnt, user_bad_cnt);
        varList[14] = getVar14(call_total_time, user_outgo_number);
        varList[15] = getVar15(call_outgo_cnt, call_night_cnt);
        varList[16] = getVar16(call_time60_cnt, user_bad_cnt);
        varList[17] = getVar17(call_total_time, call_afternoon_cnt, user_number);
        varList[18] = getVar18(user_morning_number, user_afternoon_number);
        varList[19] = getVar19(user_bad_cnt, user_income_cnt);
        varList[20] = getVar20(call_outgo_cnt, call_avg_time);
        varList[21] = getVar21(call_outgo_cnt, user_outgo_cnt, call_night_cnt);
        varList[22] = getVar22(call_bad_cnt, call_total_time);
        varList[23] = getVar23(call_night_cnt, call_time0_cnt, user_outgo_cnt);
        varList[24] = getVar24(user_bad_cnt, user_morning_cnt, call_time0_cnt);
        varList[25] = getVar25(user_night_number, user_income_cnt, call_time10_cnt);
        varList[26] = getVar26(call_outgo_cnt, call_avg_time);
        varList[27] = getVar27(call_time0_cnt, user_time0_number);
        varList[28] = getVar28(call_income_cnt, call_avg_time);
        varList[29] = getVar29(call_outgo_cnt, call_avg_time, call_night_cnt);

        //        for (int i = 0; i < varList.length; i++) {
        //            if(num != null && num.equals("18577457403")){
        //                LOG.error("var[" + i+ "]: " + varList[i]);
        //            }
        //            score += varList[i];
        //        }

        for (double var : varList) {
            score += var;
        }

        score = 1 - 1 / (1 + Math.exp(score));

        return score;
    }

    private static double getVar0(
            int user_bad_cnt, int user_time60_number, int call_bemorning_cnt) {
        double res;
        if (user_bad_cnt > 385.50000000000006) {
            if (user_time60_number > 278.50000000000006) {
                res = 0.7434065143386323;
            } else {
                res = 0.8463259210975166;
            }
        } else {
            if (call_bemorning_cnt > 1.0000000180025095e-35) {
                res = 0.5002067997543891;
            } else {
                res = 0.7688454318734761;
            }
        }
        return res;
    }

    private static double getVar1(int call_night_cnt, int user_time60_number) {
        double res;
        if (call_night_cnt > 1.0000000180025095e-35) {
            if (call_night_cnt > 1.5000000000000002) {
                res = -0.2813790597466673;
            } else {
                res = -0.10312046260934023;
            }
        } else {
            if (user_time60_number > 113.50000000000001) {
                res = -0.012965591034726144;
            } else {
                res = 0.033745990525794634;
            }
        }
        return res;
    }

    private static double getVar2(int call_time60_cnt, int call_time10_cnt) {
        double res;
        if (call_time60_cnt > 1.0000000180025095e-35) {
            if (call_time10_cnt > 1.0000000180025095e-35) {
                res = -0.24753797615220915;
            } else {
                res = -0.15205851587216976;
            }
        } else {
            if (call_time10_cnt > 1.0000000180025095e-35) {
                res = 0.039241971460348024;
            } else {
                res = -0.02477801638587673;
            }
        }
        return res;
    }

    private static double getVar3(int call_time60_cnt, int user_bad_number) {
        double res;
        if (call_time60_cnt > 1.0000000180025095e-35) {
            if (call_time60_cnt > 1.5000000000000002) {
                res = -0.22101024369503586;
            } else {
                res = -0.13340923873717705;
            }
        } else {
            if (user_bad_number > 181.50000000000003) {
                res = 0.04213344740997881;
            } else {
                res = -0.023895151912604825;
            }
        }
        return res;
    }

    private static double getVar4(int call_cnt, double call_avg_time) {
        double res;
        if (call_cnt > 1.5000000000000002) {
            if (call_avg_time > 2.5131578947368425) {
                res = -0.17874242711559338;
            } else {
                res = 0.0003792796649123607;
            }
        } else {
            if (call_avg_time > 4.5357142857142865) {
                res = -0.021351510286672246;
            } else {
                res = 0.06124116393088504;
            }
        }
        return res;
    }

    private static double getVar5(
            int call_outgo_cnt, int user_morning_number, int user_time0_number) {
        double res;
        if (call_outgo_cnt > 1.0000000180025095e-35) {
            if (user_morning_number > 490.50000000000006) {
                res = -0.24754413502897643;
            } else {
                res = -0.21496796997616396;
            }
        } else {
            if (user_time0_number > 399.50000000000006) {
                res = 0.05909880246732574;
            } else {
                res = 0.028206072957400033;
            }
        }
        return res;
    }

    private static double getVar6(int call_time60_cnt, int user_morning_number) {
        double res;
        if (call_time60_cnt > 1.0000000180025095e-35) {
            if (call_time60_cnt > 1.5000000000000002) {
                res = -0.15578932609676707;
            } else {
                res = -0.09775907569010768;
            }
        } else {
            if (user_morning_number > 2039.0000000000002) {
                res = -0.16365045955641183;
            } else {
                res = 0.01594030794742837;
            }
        }
        return res;
    }

    private static double getVar7(int call_cnt, int call_night_cnt) {
        double res;
        if (call_cnt > 1.5000000000000002) {
            if (call_cnt > 2.5000000000000004) {
                res = -0.14064922857668524;
            } else {
                res = -0.056044210523202576;
            }
        } else {
            if (call_night_cnt > 1.0000000180025095e-35) {
                res = -0.06522564196287772;
            } else {
                res = 0.02889038018388968;
            }
        }
        return res;
    }

    /** var8 */
    private static double getVar8(double call_total_time, int user_outgo_number) {
        double res;
        if (call_total_time > 5.500000000000001) {
            if (call_total_time > 61.50000000000001) {
                res = -0.1079314687606948;
            } else {
                res = -0.030689676289990676;
            }
        } else {
            if (user_outgo_number > 770.5000000000001) {
                res = -0.052895138143488646;
            } else {
                res = 0.050178027984375144;
            }
        }
        return res;
    }
    /** var9 */
    private static double getVar9(int call_time10_cnt, int user_time0_number) {
        double res;
        if (call_time10_cnt > 2.5000000000000004) {
            if (user_time0_number > 477.50000000000006) {
                res = -0.049329043553149265;
            } else {
                res = -0.12526963624362594;
            }
        } else {
            if (call_time10_cnt > 1.0000000180025095e-35) {
                res = 0.02447910268275722;
            } else {
                res = -0.029641940553986574;
            }
        }
        return res;
    }
    /** var10 */
    private static double getVar10(int call_cnt, int user_number) {
        double res;
        if (call_cnt > 1.5000000000000002) {
            if (call_cnt > 2.5000000000000004) {
                res = -0.11653921933773898;
            } else {
                res = -0.04853257684239146;
            }
        } else {
            if (user_number > 3058.0000000000005) {
                res = -0.06867218865569856;
            } else {
                res = 0.020960867069804677;
            }
        }
        return res;
    }

    /** var11 */
    private static double getVar11(int call_time60_cnt, int call_bemorning_cnt) {
        double res;
        if (call_time60_cnt > 1.0000000180025095e-35) {
            if (call_time60_cnt > 1.5000000000000002) {
                res = -0.11693438776081405;
            } else {
                res = -0.06738322901451063;
            }
        } else {
            if (call_bemorning_cnt > 1.0000000180025095e-35) {
                res = -0.21451881427418945;
            } else {
                res = 0.011641494111108961;
            }
        }
        return res;
    }
    /** var12 */
    private static double getVar12(double call_avg_time, int user_bad_cnt) {
        double res;
        if (call_avg_time > 1.0500000000000003) {
            if (user_bad_cnt > 552.5000000000001) {
                res = -0.016351568082615116;
            } else {
                res = -0.05207950932518032;
            }
        } else {
            if (user_bad_cnt > 504.50000000000006) {
                res = 0.05591027173864001;
            } else {
                res = 0.023099206567872232;
            }
        }
        return res;
    }
    /** var13 */
    private static double getVar13(int call_outgo_cnt, int call_afternoon_cnt, int user_bad_cnt) {
        double res;
        if (call_outgo_cnt > 1.0000000180025095e-35) {
            if (call_afternoon_cnt > 1.5000000000000002) {
                res = -0.13105426619519567;
            } else {
                res = -0.1886289325873818;
            }
        } else {
            if (user_bad_cnt > 626.5000000000001) {
                res = 0.0484934977038482;
            } else {
                res = 0.021773584868810134;
            }
        }
        return res;
    }
    /** var14 */
    private static double getVar14(double call_total_time, int user_outgo_number) {
        double res;
        if (call_total_time > 4.500000000000001) {
            if (call_total_time > 74.50000000000001) {
                res = -0.08046868137642786;
            } else {
                res = -0.02361395882505292;
            }
        } else {
            if (user_outgo_number > 669.5000000000001) {
                res = -0.039618653216609644;
            } else {
                res = 0.03924934247883383;
            }
        }
        return res;
    }
    /** var15 */
    private static double getVar15(int call_outgo_cnt, int call_night_cnt) {
        double res;
        if (call_outgo_cnt > 1.0000000180025095e-35) {
            if (call_outgo_cnt > 2.5000000000000004) {
                res = -0.12848598897943217;
            } else {
                res = -0.15810005383125092;
            }
        } else {
            if (call_night_cnt > 1.0000000180025095e-35) {
                res = -0.030968715694775696;
            } else {
                res = 0.03264677864004871;
            }
        }
        return res;
    }
    /** var16 */
    private static double getVar16(int call_time60_cnt, int user_bad_cnt) {
        double res;
        if (call_time60_cnt > 1.0000000180025095e-35) {
            if (call_time60_cnt > 1.5000000000000002) {
                res = -0.089661149834459;
            } else {
                res = -0.043680180892619984;
            }
        } else {
            if (user_bad_cnt > 323.50000000000006) {
                res = 0.019589097390263252;
            } else {
                res = -0.018266681578071566;
            }
        }
        return res;
    }
    /** var17 */
    private static double getVar17(
            double call_total_time, int call_afternoon_cnt, int user_number) {
        double res;
        if (call_total_time > 5.500000000000001) {
            if (call_afternoon_cnt > 1.5000000000000002) {
                res = -0.09238087458147942;
            } else {
                res = -0.022137996145662378;
            }
        } else {
            if (user_number > 415.50000000000006) {
                res = 0.03562321566202667;
            } else {
                res = 0.017078904094966315;
            }
        }
        return res;
    }
    /** var18 */
    private static double getVar18(int user_morning_number, int user_afternoon_number) {
        double res;
        if (user_morning_number > 2039.0000000000002) {
            if (user_afternoon_number > 3480.5000000000005) {
                res = -0.15377881617784883;
            } else {
                res = -0.08496824177235267;
            }
        } else {
            if (user_morning_number > 212.50000000000003) {
                res = 0.00851873551854719;
            } else {
                res = -0.013372867251539085;
            }
        }
        return res;
    }
    /** var19 */
    private static double getVar19(int user_bad_cnt, int user_income_cnt) {
        double res;
        if (user_bad_cnt > 513.5000000000001) {
            if (user_income_cnt > 1513.5000000000002) {
                res = -0.017935325378715627;
            } else {
                res = 0.028715062361896672;
            }
        } else {
            if (user_bad_cnt > 182.50000000000003) {
                res = -0.006185619988260008;
            } else {
                res = -0.03408610227576766;
            }
        }
        return res;
    }
    /** var20 */
    private static double getVar20(int call_outgo_cnt, double call_avg_time) {
        double res;
        if (call_outgo_cnt > 1.0000000180025095e-35) {
            if (call_avg_time > 60.034090909090914) {
                res = -0.09217532074435725;
            } else {
                res = -0.1445680661987038;
            }
        } else {
            if (call_avg_time > 1.0000000180025095e-35) {
                res = 0.006280046236546622;
            } else {
                res = 0.04193384609218437;
            }
        }
        return res;
    }
    /** var21 */
    private static double getVar21(int call_outgo_cnt, int user_outgo_cnt, int call_night_cnt) {
        double res;
        if (call_outgo_cnt > 1.0000000180025095e-35) {
            if (user_outgo_cnt > 1015.5000000000001) {
                res = -0.1349075094140639;
            } else {
                res = -0.10613753214769611;
            }
        } else {
            if (call_night_cnt > 1.0000000180025095e-35) {
                res = -0.03224026467489951;
            } else {
                res = 0.026820411278942476;
            }
        }
        return res;
    }
    /** var22 */
    private static double getVar22(int call_bad_cnt, double call_total_time) {
        double res;
        if (call_bad_cnt > 1.0000000180025095e-35) {
            if (call_total_time > 119.50000000000001) {
                res = -0.06525096148928765;
            } else {
                res = 0.038440684306031994;
            }
        } else {
            if (call_total_time > 7.500000000000001) {
                res = -0.048041210617341346;
            } else {
                res = -0.02022179756004564;
            }
        }
        return res;
    }
    /** var23 */
    private static double getVar23(int call_night_cnt, int call_time0_cnt, int user_outgo_cnt) {
        double res;
        if (call_night_cnt > 1.0000000180025095e-35) {
            if (call_time0_cnt > 1.0000000180025095e-35) {
                res = -0.032743062151547875;
            } else {
                res = -0.09181720623889039;
            }
        } else {
            if (user_outgo_cnt > 1384.5000000000002) {
                res = -0.015464494872479216;
            } else {
                res = 0.013892596042419339;
            }
        }
        return res;
    }

    /** var24 */
    private static double getVar24(int user_bad_cnt, int user_morning_cnt, int call_time0_cnt) {
        double res;
        if (user_bad_cnt > 808.5000000000001) {
            if (user_morning_cnt > 1979.0000000000002) {
                res = -0.012517079778188254;
            } else {
                res = 0.03839773901430949;
            }
        } else {
            if (call_time0_cnt > 2.5000000000000004) {
                res = -0.07209717677281617;
            } else {
                res = -0.005247784485364115;
            }
        }
        return res;
    }
    /** var25 */
    private static double getVar25(
            int user_night_number, int user_income_cnt, int call_time10_cnt) {
        double res;
        if (user_night_number > 223.50000000000003) {
            if (user_income_cnt > 545.5000000000001) {
                res = -0.02992055392125467;
            } else {
                res = -0.07551155886055755;
            }
        } else {
            if (call_time10_cnt > 3.5000000000000004) {
                res = -0.07739227626666018;
            } else {
                res = 0.0060203497668303765;
            }
        }
        return res;
    }
    /** var26 */
    private static double getVar26(int call_outgo_cnt, double call_avg_time) {
        double res;
        if (call_outgo_cnt > 1.0000000180025095e-35) {
            if (call_avg_time > 60.034090909090914) {
                res = -0.0757200455230604;
            } else {
                res = -0.12000654012803713;
            }
        } else {
            if (call_avg_time > 1.0000000180025095e-35) {
                res = 0.006748578899083552;
            } else {
                res = 0.033130963807990875;
            }
        }
        return res;
    }
    /** var27 */
    private static double getVar27(int call_time0_cnt, double user_time0_number) {
        double res;
        if (call_time0_cnt > 1.0000000180025095e-35) {
            if (call_time0_cnt > 2.5000000000000004) {
                res = -0.04756362474912293;
            } else {
                res = 0.013680486830284784;
            }
        } else {
            if (user_time0_number > 210.50000000000003) {
                res = -0.02232814754431739;
            } else {
                res = -1.5397644931255046e-05;
            }
        }
        return res;
    }
    /** var28 */
    private static double getVar28(int call_income_cnt, double call_avg_time) {
        double res;
        if (call_income_cnt > 1.5000000000000002) {
            if (call_avg_time > 5.071428571428572) {
                res = -0.09427513587024158;
            } else {
                res = 0.0022583085433542107;
            }
        } else {
            if (call_avg_time > 1.0000000180025095e-35) {
                res = -0.008340219854934165;
            } else {
                res = 0.019337686550955913;
            }
        }
        return res;
    }

    private static double getVar29(int call_outgo_cnt, double call_avg_time, int call_night_cnt) {
        double res;
        if (call_outgo_cnt > 1.0000000180025095e-35) {
            if (call_avg_time > 63.040000000000006) {
                res = -0.06583109720194744;
            } else {
                res = -0.1107779934288482;
            }
        } else {
            if (call_night_cnt > 1.0000000180025095e-35) {
                res = -0.022704674794119292;
            } else {
                res = 0.020893286882102173;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        String varPhoneTags = getVarPhoneTags("4007730618");
        System.out.println(varPhoneTags);

//        String s = forMattedPhoneNumber("1008611");
//        System.out.println("formatNumber: " + s);
//        System.out.println("isMobile: " + isMobile(s));
    }
}
